from constants import END_MARK


def decode_if_needed(s):
    # 如果字符串包含转义序列 \u，尝试转义
    if "\\u" in s:
        try:
            return s.encode('utf-8').decode('unicode_escape')
        except UnicodeDecodeError:
            return s  # 解码失败返回原字符串
    # 否则，直接返回原字符串
    return s


def check_is_end(text):
    return END_MARK in text
